package com.hhd.cwqs.qs;

import com.hhd.cwqs.entity.CwqsLogDetail;
import com.hhd.cwqs.entity.CwqsUnit;
import com.hhd.cwqs.qs.service.PkBuilder;
import com.hhd.cwqs.qs.sql.SingleConnJdbcTemplate;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.List;

@Getter
@Setter
public class Params {
    private Context context;
    private SingleConnJdbcTemplate sourceSqlTemplate;
    private SingleConnJdbcTemplate targetSqlTemplate;
    private String accountingSystem;

    private String year;
    private List<String> monthes;

    private CwqsUnit unit;
    PackageData packageData = new PackageData();
    PkBuilder pkBuilder;

    public CwqsLogDetail createLog(String message) {
        CwqsLogDetail res = new CwqsLogDetail();
        res.setUnitId(unit.getId());
        res.setYear(year);
        context.addDetailLog(res);
        res.setMessage(message);
        res.setCreateTime(new Date());
        return res;
    }

    public void createPkBuilder() {
        pkBuilder = PkBuilder.forParams(this);
    }

    public String ACCT_SET_CODE() {
        return unit.getAccountingCode();
    }


    public String unitCode() {
        return unit.getUnitCode();
    }
}
